The following guidelines help you to produce portable code. Use these guidelines when you are developing new code or as you identify portability problems in existing code.
typedef signed char int8_t
typedef unsigned char uint8_t
...
typedef unsigned long long uint64_t
typedef signed long intscaled_t
typedef unsigned long uintscaled_t
After you construct the above header file, use the new typedef types instead of the standard C type names. You may need a distinct copy of this header file (or conditional code) for each target platform supported.
If you provide libraries or interfaces to be used by others, be careful to use these types (or similar application-specific types) chosen to match the specific requirements of the interface. Also, carefully choose the actual names used to avoid namespace conflicts with other libraries. Thus, your clients should be able to use a single set of header files on all targets. However, you will always need to provide distinct libraries (binaries) for the 32-bit compatibility mode and the 64-bit native mode on 64-bit Silicon Graphics platforms, although the sources can be identical.
#define _fmt32 "%d"
#define _fmt32u "%u"
#define _fmt64 "%lld"
#define _fmt64u "%llu"
The inttypes.h header file also defines printf/scanf format extensions to standardize these practices. They are implemented by the first release of the 64-bit compilers and related tools.
This chapter provides guidelines for porting code.